home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / B-C / C++ FAQ Reference 1.0 / C++ FAQ Reference 1.0.rsrc / TEXT_828.txt < prev    next >
Encoding:
Text File  |  1993-06-30  |  911 b   |  5 lines

  1. Constructors (ctors) do not return any values, so no returned error code is possible.  There are many possibilities for how to handle this, one of which is to set the object itself into a 'half baked' state by setting an internal status bit.  Naturally there should be a query ('inspector') method to check this bit, allowing clients to discover whether they have a live object.  Other member functions should check this bit, and either do a no-op (or perhaps something more obnoxious such as 'abort()') if the object isn't really alive.  Check out how the iostreams package handles attempts to open nonexistent/illegal files for an example of prior art.
  2.  
  3. One more thing: you might want to store information indicating *why* the failure took place in addition to a 'failure bit'.
  4.  
  5. When real exceptions come to C++, they will provide a better strategy; the best technique will generally be to throw an exception.